﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BusinnessLogic;

namespace scrumbench
{
    public partial class NewUserstory : Form
    {
        public NewUserstory()
        {
            InitializeComponent();
        }

        public NewUserstory(int sprintid, string sprintttitel)
        {
            InitializeComponent();
            this.sprintid = sprintid;
            this.sprintttitel = sprintttitel;

        }

        private int sprintid;

        public int Sprintid
        {
            get { return sprintid; }
            set { sprintid = value; }
        }

        private string sprintttitel;

        public string Sprintttitel
        {
            get { return sprintttitel; }
            set { sprintttitel = value; }
        }



        private void NewUserstory_Load(object sender, EventArgs e)
        {
            this.Text = this.Text + " " + this.sprintttitel;
            this.lblUnderText.Text = this.lblUnderText.Text + " " + this.sprintttitel;

        }

        private void btCreate_Click(object sender, EventArgs e)
        {
            int bw;
            ManageUserStoryList ulmanager = new ManageUserStoryList();
            if (tBxUSTitel.Text == null)
            {
                MessageBox.Show("Please give a UserStory Titel"); 

            }
            else if (tBxUSBusWeight.Text == "" || !(int.TryParse(tBxUSBusWeight.Text,out bw)))
            {
                MessageBox.Show("Please give a Business Weight in numerical value");
            }
            else if (tBxUSDescription.Text != "")
            {
                ulmanager.AddUserStory(sprintid, tBxUSTitel.Text, int.Parse(tBxUSBusWeight.Text));
                this.Close();
            }
            else
            {
                ulmanager.AddUserStory(sprintid, tBxUSTitel.Text, tBxUSDescription.Text, int.Parse(tBxUSBusWeight.Text));
                this.Close();
            }
            
        }

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void lblUnderText_Click(object sender, EventArgs e)
        {

        }




    }
}
